package leetcode.median;

import leetcode.base.TreeNode;

/**
 * ClassName: $538_ConvertBST
 * Description:
 * date: 2021-12-08 9:01
 *
 * @author liyifan
 */
public class $538_ConvertBST {
    int sum = 0;
    public TreeNode convertBST(TreeNode root) {
        recur(root);
        return root;
    }

    void recur(TreeNode root){
        if (root == null)
            return;
        recur(root.right);
        sum += root.val;
        root.val = sum;
        recur(root.left);
    }
}
